'''
用集合SUM
'''
print('普通列表sum写法')
max = 1000
list = []
for i in range(2,max):
    for j in range(1,i):
        if i % j == 0:
            list.append(j)
    if i == sum(list):
        print(f'完数 {i}  他的因子 {list}')
    list.clear()


'''
推导式的语法
'''
print('推导式语法结果')
max = 1000
list = []
for i in range(2,max):
    list=[j for j in range(1, i) if i % j == 0]
    sum_value = sum(list)
    if i == sum_value:
        print(f'完数 {i}  他的因子 {list}')

'''
数值累加,要单独记录因子
'''
print('数值累加方法')
max = 1000
for i in range(2,max):
    sum_value = 0
    for j in range(1, i):
        if i % j == 0:
            sum_value+=j
    if i == sum_value:
        print(f'完数 {i}')